package com.mark.segmentword;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class TextKeywordFrequency {
	private Map<String,Integer> mapData = new HashMap<String, Integer>();
	private List<String> tempDataSet = new ArrayList<String>();
	
	public TextKeywordFrequency(){
		
	}
	
	public void setDataSet(List<String> dataSet){
		tempDataSet = dataSet;
	}
	
	public Map<String,Integer> getReasult(){
		return this.mapData;
	}
	
	public void executeTrainFrequency(){
		for (Iterator<String> iterator = tempDataSet.iterator(); iterator.hasNext();) {
			String string = (String) iterator.next();
			String[] ar = string.split(" ");
			for (int i = 0; i < ar.length; i++) {
				if( mapData.containsKey(ar[i]) ){
				    mapData.put(ar[i], mapData.get(ar[i])+1);
				}else{
					mapData.put(ar[i], 1);
				}		
			}
		}
	}
	
	
	
	

}
